<?php 
date_default_timezone_set('PRC');
set_time_limit(30);
$recordFileName = 'r_view.txt';

if (!file_exists($recordFileName)) {
    file_put_contents($recordFileName, '{"baba":{"0":0}');
}

$json = file_get_contents($recordFileName);
$arr = json_decode($json,true);
$res = 'baba';
$arr[$res][0] = isset($arr[$res][0]) ? $arr[$res][0] : 0;
$arr[$res][0] ++;
//////////////////////////////
$time = strtotime(date('Y-m-d H:00:00'));
$arr[$res][$time] = isset($arr[$res][$time]) ? $arr[$res][$time] : 0;
$arr[$res][$time] ++;
//////////////////////////////
$json = json_encode($arr);
if(strlen($json) > 10)
{
    file_put_contents($recordFileName,$json);
}
